package com.jl.slick.util.display;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import org.newdawn.slick.AppGameContainer;

public class LaunchMenu extends Frame implements ActionListener,
WindowListener 
{

	CheckboxGroup resolutions;
	Checkbox one;
	Checkbox two;
	Checkbox three;
	Checkbox fs;
	Button launch;
	AppGameContainer change;
	//org.newdawn.slick.Graphics scale;
	
	public LaunchMenu(AppGameContainer change)
	{
		resolutions = new CheckboxGroup();
		one = new Checkbox("1920x1080", resolutions, true);
		two = new Checkbox("1024x768", resolutions, false);
		three = new Checkbox("800x600", resolutions, false);
		fs = new Checkbox("Fullscreen", true);
		Button launch = new Button("Launch");
		
		this.setLayout(new GridLayout(3,3));
		
		launch.addActionListener(this);
		
		this.add(one);
		this.add(two);
		this.add(three);
		this.add(fs);
		this.add(launch);
		
		this.setSize(300, 300);
		this.setVisible(true);
		this.change = change;
	//	this.scale = scale;
	}
	
	
	
	
	
	@Override
	public void windowActivated(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowClosed(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowClosing(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeactivated(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeiconified(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowIconified(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowOpened(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void actionPerformed(ActionEvent arg0)
	{
	try
	{

			if(one.getState())//1920x1080 selected
			{
				change.setDisplayMode(1920, 1080, fs.getState());
			//	scale.scale((float)0.5333333333333333333333333333333334, (float)0.7111111111111111111111111111112);
			}
			
			if(two.getState())//1024x768 selected. DEFAULT SCALING for tilesets 32x32
			{
				change.setDisplayMode(1024, 768, fs.getState());
			//	scale.scale(1, 1);
			}
			
			if(three.getState())//800x600 selected
			{
				change.setDisplayMode(800, 600, fs.getState());
			//	scale.scale((float) 1.28, (float)1.28);
			}
			change.start();
			return;

	}
	catch(Exception e)
	{
		System.err.println("Error Setting Display");
		e.printStackTrace();
	}
	}

}
